home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / GraphicViewers / pCD / Source / hpcdtoppm.0.4 / hpcdtoppm.h < prev    next >
C/C++ Source or Header  |  1993-03-23  |  4KB  |  168 lines

  1. /* hpcdtoppm (Hadmut's pcdtoppm) v0.4
  2. *  Copyright (c) 1992, 1993 by Hadmut Danisch (danisch@ira.uka.de).
  3. *  Permission to use and distribute this software and its
  4. *  documentation for noncommercial use and without fee is hereby granted,
  5. *  provided that the above copyright notice appear in all copies and that
  6. *  both that copyright notice and this permission notice appear in
  7. *  supporting documentation. It is not allowed to sell this software in 
  8. *  any way. This software is not public domain.
  9. */
  10.  
  11.  
  12. #include "config.h"
  13. #include <stdio.h>
  14. #include <string.h>
  15. #ifdef __NeXT__
  16. #   include <stdlib.h>
  17. #else
  18. #   include <malloc.h>
  19. #endif
  20. #include <sys/types.h>
  21. #include <ctype.h>
  22.  
  23.  
  24.  
  25. /* Format definitions */
  26.  
  27. #define BaseW ((dim)768)
  28. #define BaseH ((dim)512)
  29.  
  30. #define SECSIZE 0x800
  31.  
  32.  
  33. #define SeHead   2
  34. #define L_Head   (1+SeHead)
  35.  
  36. #define SeBase16 18
  37. #define L_Base16 (1+SeBase16)
  38.  
  39. #define SeBase4  72
  40. #define L_Base4  (1+SeBase4)
  41.  
  42. #define SeBase   288
  43. #define L_Base   (1+SeBase)
  44.  
  45.  
  46. #define neutrLum 128
  47. #define neutrCh1 156
  48. #define neutrCh2 137
  49.  
  50.  
  51.  
  52.  
  53.  
  54. /* Structures and definitions */
  55. struct _implane
  56.  {dim  mwidth,mheight,
  57.        iwidth,iheight;
  58.   uBYTE *im,*mp;
  59.  };
  60. typedef struct _implane implane;
  61.  
  62. #define nullplane ((implane *) 0)
  63.  
  64. enum   TURNS  { T_UNSPEC,T_NONE,T_RIGHT,T_LEFT,T_AUTO };
  65. enum   SIZES  { S_UNSPEC,S_Base16,S_Base4,S_Base,S_4Base,S_16Base,S_Over,S_Contact };
  66. enum   OUTFOR { O_UNSPEC,O_PPM,O_PGM,O_YCC,O_PS,O_EPS,O_PSG,O_EPSG };
  67. enum   CORR   { C_UNSPEC,C_LINEAR,C_DARK,C_BRIGHT };
  68.  
  69. enum   ERRORS { E_NONE,E_READ,E_WRITE,E_INTERN,E_ARG,E_OPT,E_MEM,E_HUFF,
  70.                 E_SEQ,E_SEQ1,E_SEQ2,E_SEQ3,E_SEQ4,E_SEQ5,E_SEQ6,E_SEQ7,E_POS,E_IMP,E_OVSKIP,
  71.                 E_TAUTO,E_TCANT };
  72.  
  73.  
  74. /* Macros */
  75. #ifdef DEBUG
  76.  
  77. extern long bufpos;
  78. #define SEEK(x) { if (fseek(fin,((x) * SECSIZE),0)) error(E_READ);\
  79.                   fprintf(stderr,"S-Position %x\n",ftell(fin)); }
  80. #define RPRINT  {fprintf(stderr,"R-Position %x\n",ftell(fin));}
  81. #define READBUF   (bufpos=ftell(fin),fread(sbuffer,sizeof(sbuffer),1,fin))
  82.  
  83. #else
  84.  
  85. #define SEEK(x) { if (fseek(fin,((x) * SECSIZE),0)) error(E_READ);}
  86. #define RPRINT
  87. #define READBUF   fread(sbuffer,sizeof(sbuffer),1,fin)
  88.  
  89. #endif
  90.  
  91.  
  92.  
  93. #define melde(x) {if (do_melde) fprintf(stderr,x);}
  94.  
  95.  
  96. #define EREADBUF {if(READBUF < 1) error(E_READ);}
  97.  
  98. #define SKIP(n)  { if (fseek(fin,(n),1)) error(E_READ);}
  99. #define SKIPr(n) { if (fseek(fin,(n),1)) return(E_READ);}
  100.  
  101.  
  102. #define TRIF(x,u,o,a,b,c) ((x)<(u)? (a) : ( (x)>(o)?(c):(b)  ))
  103. #define xNORM(x) x=TRIF(x,0,255,0,x,255)
  104. #define NORM(x) { if(x<0) x=0; else if (x>255) x=255;}
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117. /* main.c */
  118. extern void         close_all();
  119. extern FILE         *fin,*fout;
  120. extern char         *ppmname,*pcdname;
  121. extern int          do_diff,do_info,do_sharp,do_overskip,monochrome;
  122. extern int          do_melde,do_rep,do_crop;
  123. extern int          flvert,flhori;
  124. extern uBYTE        sbuffer[SECSIZE];
  125. extern enum TURNS   turn;
  126. extern enum SIZES   size;
  127. extern enum OUTFOR  outfor;
  128. extern enum CORR    corrmode;
  129.  
  130. extern float        PAPER_LEFT,PAPER_BOTTOM,PAPER_WIDTH,PAPER_HEIGHT;
  131.  
  132. /* error.c */
  133. extern void         error();
  134.  
  135.  
  136. /* color.c */
  137. extern void         sharpit();
  138. extern void         colconvert();
  139.  
  140. /* tools.c */
  141. extern long         Skip4Base();
  142. extern void         clear();
  143. extern void         halve();
  144. extern void         interpolate();
  145. extern void         planealloc();
  146. extern void         pastein();
  147. extern void         cropit();
  148.  
  149. /* format.c */
  150. extern void         decode();
  151. extern void         readhqt();
  152. extern enum ERRORS  readplain();
  153.  
  154. /* output.c */
  155. extern void         druckeid();
  156. extern void         writepicture();
  157.  
  158. /* ppm.c */
  159. extern void         write_pgm();
  160. extern void         write_ppm();
  161.  
  162. /* postscr.c */
  163. extern void         write_epsgrey();
  164. extern void         write_psgrey();
  165. extern void         write_epsrgb();
  166. extern void         write_psrgb();
  167.  
  168.